//
//  HXActiveView.m
//  爱鲜蜂
//
//  Created by 建国 on 16/5/4.
//  Copyright © 2016年 建国. All rights reserved.
//

#import "HXActiveView.h"
#import "HXButton.h"
@implementation HXActiveView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        for (int i = 0 ;  i < 4; i++) {
            HXButton *button = [[HXButton alloc]init];
#warning 修改
            [button setTitle:@"活动" forState:(UIControlStateNormal)];
            [button setImage:[UIImage imageNamed:@"feedBack_service"] forState:(UIControlStateNormal)];
            [self addSubview:button];
        }
    }
    return self;
}
-(void)layoutSubviews {
    
    [super layoutSubviews];
    NSInteger count = self.subviews.count ;
    CGFloat buttonW = self.width / count ;
    CGFloat buttonH = self.height ;
    
    
    for (int i = 0; i < count ; i++) {
        HXButton *button = self.subviews[i];
        CGFloat buttonX = i * buttonW ;
        button.frame = CGRectMake(buttonX, 0, buttonW, buttonH);
        button.tag = i ;
        [button addTarget:self action:@selector(active : ) forControlEvents:(UIControlEventTouchUpInside)] ;
    }
}

-(void)active :(HXButton *)button {
    NSLog(@"点击了第%ld个按钮",(long)button.tag);
}


@end
